<?php
global $VALUTA, $MONTHS2;
?>
<script language="javascript" src='<?=config_item('js_path')?>js/oper_index.js?<?=time()?>'></script>
<h1>Операции десятки</h1>
<a href='#' onclick="openFilter(); return false;"><img src='<?=config_item('image_path')?>images/icons/funnel.png' width='16' height='16' title='' align=left style="margin-right:5px;"> Фильтр</a> <br><br>
<form method=get action='' enctype='multipart/form-data' id='filter' <?php if(!$is_open_filter) { ?>style='display:none;'<?php } ?>>
<input type='hidden' name='f' value='1'>
<input type='hidden' name='u' value=''>
<input type='hidden' name='t' value=''>
<table class='edit' cellspacing=0 style="width:100%">
<tr>
	<td>Тип операции:</td>
	<td width=100% id='types'>
		<div><input type='checkbox' value='' onchange="selectTypeAll(this)"> <b>Все</b></div>
		<?php foreach ($type_oper as $k => $v) { ?>
			<div><input type='checkbox' value='<?=$k?>' <?php if(@$filter['type'] && is_array($filter['type']) && in_array($k, $filter['type'])) echo "checked"; ?>> <?=$v?></div>
		<?php } ?>
	</td>
</tr>
<tr>
	<td valign=top>Участники:</td>
	<td>
		<div id="structure" class="">
			<div><input type='checkbox' value='' onchange="selectTypeAll(this)"> <b>Все</b></div>
			<?
			function printUsersStructure($users, $selected, $inc_des, $level = 0)
			{
				foreach($users as $u)
				{
					$ch = is_array($selected) && in_array($u['id'], $selected) ? "checked" : '';
					echo "<div style='padding-left:".($level * 30)."px;'><input type='checkbox' value='".$u['id']."' ".$ch."> ".$u['fio']." (".$u['email'].")";
					if($u['level'] && $level)
					{
						$ch2 = is_array($inc_des) && in_array($u['id'], $inc_des) ? "checked" : '';
						echo "<input type='checkbox' name='inc_des[]' value='".$u['id']."' ".$ch2." style='margin-left:30px;'> Показать операции по всей десятке";
					}
					echo "</div>\n";
					if(@$u['children'])
					{
						printUsersStructure($u['children'], $selected, $inc_des, $level + 1);
					}
				}
			}
			printUsersStructure($structure, @$filter['users_id'], @$filter['inc_des']);
			?>
		</div>
	</td>
</tr>
<tr>
	<td>Колонки:</td>
	<td width=100%>
		<div><input type='checkbox' value='frozen' name='col[]' <?php if(in_array('frozen', $filter['col'])) echo 'checked'; ?>> Срок и сумма разморозки</div>
		<div><input type='checkbox' value='platezh' name='col[]' <?php if(in_array('platezh', $filter['col'])) echo 'checked'; ?>> Связанные платежи</div>
	</td>
</tr>
</table>
<br>
<input type='button' value='Применить' onclick="submFilter(document.getElementById('filter'));">
</form>


<?php if(@$filter['last_oper']) {?>
	<center><span style='font-size:16px;'><b>Внимание!</b></span><br>
	Показана ТОЛЬКО последняя проведённая операция<br>а также связанные с ней.</center><br><br>
<?php } ?>

<?php $this->load->view('oper/_table', array(
	'users' => $users, 
	'params' => array(
		'platezh' => in_array('platezh', $filter['col']), 
		'show_frozen' => in_array('frozen', $filter['col']),
		'link_user_info' => true,
	)
	));
?>

<br><br><br>
<h1>Внешние рефереры</h1>
<?php $this->load->view('oper/_table', array('users' => $referer_users, 'params' => array('kro' => false, 'balance' => true, 'actions' => false))); ?>
